package com.metal.gear.certification.entity.po;

import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.metal.gear.common.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 * 部门表
 * <p>
 * 
 * @Author Steve
 * @Since  2019-01-22
 */
@Data
@TableName("sys_depart")
public class SysDepart implements Serializable {
    private static final long serialVersionUID = 1L;
    
	@TableId(type = IdType.ASSIGN_ID)
	@Schema(name ="组织机构Id，departId")
	private String id;

	@Schema(name ="父机构ID")
	private String parentId;

	@ExcelProperty("机构/部门名称")
	@Schema(name ="组织机构名称")
	private String departName;

	@ExcelProperty("英文名")
	@Schema(name ="英文名")
	private String departNameEn;

	@Schema(name ="缩写")
	private String departNameAbbr;

	@ExcelProperty("排序")
	@Schema(name ="排序码")
	private Integer departOrder;

	@Schema(name ="描述")
	@ExcelProperty("描述")
	private String description;

	@Schema(name ="机构类别（1=公司，2=组织机构，3=岗位）")
	@ExcelProperty("机构类别")
	private String orgCategory;

	@Schema(name ="机构类型")
	private String orgType;

	@Schema(name ="机构编码")
	@ExcelProperty("机构编码")
	private String orgCode;

	@Schema(name ="手机号")
	@ExcelProperty("手机号")
	private String mobile;

	@Schema(name ="传真")
	@ExcelProperty("传真")
	private String fax;

	@Schema(name ="地址")
	@ExcelProperty("地址")
	private String address;

	@Schema(name ="备注")
	@ExcelProperty("备注")
	private String memo;

	@Schema(name ="状态（1启用，0不启用）")
	@Dict(dicCode = "depart_status")
	private String status;

	@Dict(dicCode = "del_flag")
	@Schema(name ="删除状态（0，正常，1已删除）")
	private String delFlag;

	@Schema(name ="对接企业微信的ID")
	private String qywxIdentifier;

	@Schema(name ="创建人")
	private String createBy;

	@Schema(name ="创建日期")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	@Schema(name ="更新人")
	private String updateBy;

	@Schema(name ="更新日期")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date updateTime;

	@Schema(name ="部门负责人的ids")
	@TableField(exist = false)
	private String directorUserIds;

	@Schema(name ="旧的部门负责人的ids(用于比较删除和新增)")
	@TableField(exist = false)
    private String oldDirectorUserIds;

	/**
	 * 重写equals方法
	 */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
			return true;
		}
        if (o == null || getClass() != o.getClass()) {
			return false;
		}
        if (!super.equals(o)) {
			return false;
		}
        SysDepart depart = (SysDepart) o;
        return Objects.equals(id, depart.id) &&
                Objects.equals(parentId, depart.parentId) &&
                Objects.equals(departName, depart.departName) &&
                Objects.equals(departNameEn, depart.departNameEn) &&
                Objects.equals(departNameAbbr, depart.departNameAbbr) &&
                Objects.equals(departOrder, depart.departOrder) &&
                Objects.equals(description, depart.description) &&
                Objects.equals(orgCategory, depart.orgCategory) &&
                Objects.equals(orgType, depart.orgType) &&
                Objects.equals(orgCode, depart.orgCode) &&
                Objects.equals(mobile, depart.mobile) &&
                Objects.equals(fax, depart.fax) &&
                Objects.equals(address, depart.address) &&
                Objects.equals(memo, depart.memo) &&
                Objects.equals(status, depart.status) &&
                Objects.equals(delFlag, depart.delFlag) &&
                Objects.equals(createBy, depart.createBy) &&
                Objects.equals(createTime, depart.createTime) &&
                Objects.equals(updateBy, depart.updateBy) &&
                Objects.equals(updateTime, depart.updateTime);
    }

    /**
     * 重写hashCode方法
     */
    @Override
    public int hashCode() {

        return Objects.hash(super.hashCode(), id, parentId, departName, 
        		departNameEn, departNameAbbr, departOrder, description,orgCategory, 
        		orgType, orgCode, mobile, fax, address, memo, status, 
        		delFlag, createBy, createTime, updateBy, updateTime);
    }
}
